package JdbcTest.JdbcNature;
import java.util.ResourceBundle;

/*
模拟连接数据库
 */
public class Client {
    public static void main(String[] args) {
        //利用反射机制来创建对象
        ResourceBundle Bundle = ResourceBundle.getBundle("Database");
        String s = Bundle.getString("className");
        try {
            Class c = Class.forName(s);
            JdbcConnection jdbcConnection = (JdbcConnection) c.newInstance();
            //连接数据库
            jdbcConnection.connection();
            //关闭数据库
            jdbcConnection.closeConnection();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }
}
